#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
ll xy[4][3];
void solve()
{
    ll n,m;
    cin >> n >> m;
    ll x, y;
    cin >> x >> y;
    for (ll i = 0; i < 4;i++)
    {
        xy[i][0] = x;
        xy[i][1] = y;
    }
    for (ll i = 1; i < n;i++)
    {
        cin >> x >> y;
        if(x+y>xy[0][0]+xy[0][1])
        {
            xy[0][0] = x, xy[0][1] = y;
        }
        if(x+y<xy[1][0]+xy[1][1])
        {
            xy[1][0] = x, xy[1][1] = y;
        }
        if(x-y>xy[2][0]-xy[2][1])
        {
            xy[2][0] = x, xy[2][1] = y;
        }
        if(x-y<xy[3][0]-xy[3][1])
        {
            xy[3][0] = x, xy[3][1] = y;
        }
    }
    ll ans = 1e10;
    for (ll i = 0; i < m;i++)
    {
        cin >> x >> y;
        ll min_dist = -1;
        for(ll k=0;k<4;k++)
        {
            min_dist = max(min_dist, abs(xy[k][0] - x) + abs(xy[k][1] - y));
        }
        ans = min(ans, min_dist);
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
